import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class 逆序排列 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> a = new ArrayList<Integer>();
        int n = scanner.nextInt();
        while (n!=0){
            a.add(n);
            n = scanner.nextInt();
        }
        Object[] b = a.toArray();
        int[] c = new int[b.length];
        for (int i = 0,k=b.length-1; i < b.length; i++,k--) {
            c[k] = (int) b[i];
        }
        for (int i = 0; i < c.length; i++) {
            System.out.print(c[i]+" ");
        }
    }
}
